package com.celer.generator;

import cn.hutool.core.bean.BeanUtil;
import com.apifan.common.random.entity.Area;
import com.celer.convert.*;
import com.celer.randomobj.*;

import static com.celer.generator.PersonGenerator.generatePerson;
import static com.celer.util.JsonUtils.toJsonStr;
import static com.celer.util.RandomUtil.areaSource;
import static com.celer.util.RandomUtil.financialSource;
import static com.celer.util.RandomUtil.internetSource;
import static com.celer.util.RandomUtil.otherSource;

public class CompanyGenerator {

    public static void main(String[] args) throws Exception {
        Company company = Company.builder().build();
        generateCompany(company);
        System.out.println(toJsonStr(company));
    }

    public static void generateCompany(Company company) {
        Area area = areaSource.nextArea();
        BeanUtil.copyProperties(area, company);
        company.setName(otherSource.randomCompanyName(area.getProvince()));
        company.setCreditCode(otherSource.randomSocialCreditCode());
        company.setPhone(areaSource.randomPhoneNumber(area.getProvince(), "-"));
        company.setEconomicCategory(otherSource.randomEconomicCategory().getName());
        company.setBankNumber(financialSource.randomDebitCardNo());
        company.setEmail(internetSource.randomEmail(12));
        Person contact = Person.builder().build();
        generatePerson(contact);
        CompanyConvert.INSTANCE.covertConcat(company, contact);
    }
}
